package org.hawk.gwt.ppc.parser.impl;

import org.hawk.gwt.ppc.parser.CommentDescriptor;
import org.hawk.gwt.ppc.parser.Descriptor;
import org.hawk.gwt.ppc.parser.Token;
import org.hawk.gwt.ppc.utils.PreprocessorException;
import static org.hawk.gwt.ppc.parser.impl.DescriptorParserUtils.*;

/**
 * Parser for comments. Each comment is represented by single token.
 * 
 * @author alex.bereznevatiy@gmail.com
 *
 */
final class CommentDescriptorParser implements DescriptorParser {

	public boolean accepts(Token token) {
		return token.isComment();
	}

	public Descriptor parse(TokenBasedJavaParser parser, Tokenizer tokenizer, Object...params)
			throws PreprocessorException {
		Descriptor result = new CommentDescriptorImpl(tokenizer.current());
	
		lookupNext(tokenizer, true);
		
		return result;
	}

	/**
	 * 
	 * @author alex.bereznevatiy@gmail.com
	 *
	 */
	private static class CommentDescriptorImpl extends AbstractDescriptor implements CommentDescriptor {

		public CommentDescriptorImpl(Token token) {
			addToken(token);
		}
		
	}
}
